﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TaiLieu;
using System.IO;
public partial class Member1 : System.Web.UI.UserControl
{
    public string tam = "";
    TracNghiem_Members tnmb = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        this.btnlamtiep.Enabled = false;
        Question();
    }
    protected void Question()
    {
        int dem = 1;       
        foreach (TracNghiem_Members tnmb in TracNghiem_MembersDB.GetObjectBy_Id_Level_Mem(Sessions.members.Id))
        {
            tam += " <tr><td colspan=\"2\" style=\"-moz-user-select: none; -webkit-user-select: none;\"><span> Câu :&nbsp;</span>" + tnmb.TracNghiem.question + "</td></tr>" + " <tr><td colspan=\"2\" height=\"2px\">&nbsp;</td></tr>" +
                "<tr><td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"A_" + tnmb.Id + "\" name=\"check_A_" + tnmb.Id + "\"value=\"1\" onclick=\"check_Click(" + tnmb.Id + ",'A_" + tnmb.Id + "')\">&nbsp;"+ tnmb.TracNghiem.answer1 + "</td>" +
                "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"B_" + tnmb.Id + "\" name=\"check_B_" + tnmb.Id + "\"value=\"2\" onclick=\"check_Click(" + tnmb.Id + ",'B_" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer2 + "</td></tr>" +
                 "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"C_" + tnmb.Id + "\" name=\"check_C_" + tnmb.Id + "\"value=\"3\" onclick=\"check_Click(" + tnmb.Id + ",'C_" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer3 + "</td>" +
                "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"D_" + tnmb.Id + "\" name=\"check_D_" + tnmb.Id + "\"value=\"4\" onclick=\"check_Click(" + tnmb.Id + ",'D_" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer4 + "</td></tr>"
            + " <tr><td colspan=\"2\" height=\"10px\">&nbsp;</td></tr>";
            dem++;
        }
    }
    protected void Result()
    {
        int dem = 1;
        foreach (TracNghiem_Members tnmb in TracNghiem_MembersDB.GetObjectBy_Id_Level_Mem(Sessions.members.Id))
        {
            tam += " <tr><td colspan=\"2\" style=\"-moz-user-select: none; -webkit-user-select: none;\"><span> Câu :&nbsp;</span>" + tnmb.TracNghiem.question + "</td></tr>" + " <tr><td colspan=\"2\" height=\"2px\">&nbsp;</td></tr>" +
                "<tr><td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"A" + tnmb.Id + "\" name=\"check_A" + tnmb.Id + "\"value=\"1\" onclick=\"check_Click(" + tnmb.Id + ",'A" + tnmb.Id + "')\">&nbsp;<div id=\"A" + tnmb.Id + "\">" + tnmb.TracNghiem.answer1 + "</div></td>" +
                "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"B" + tnmb.Id + "\" name=\"check_B" + tnmb.Id + "\"value=\"2\" onclick=\"check_Click(" + tnmb.Id + ",'B" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer2 + "</td></tr>" +
                 "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"C" + tnmb.Id + "\" name=\"check_C" + tnmb.Id + "\"value=\"3\" onclick=\"check_Click(" + tnmb.Id + ",'C" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer3 + "</td>" +
                "<td style=\"font-weight:bold;-moz-user-select: none; -webkit-user-select: none;\"><input type=\"checkbox\" onselect=\"\" id=\"D" + tnmb.Id + "\" name=\"check_D" + tnmb.Id + "\"value=\"4\" onclick=\"check_Click(" + tnmb.Id + ",'D" + tnmb.Id + "')\">&nbsp;" + tnmb.TracNghiem.answer4 + "</td></tr>"
            + " <tr><td colspan=\"2\" height=\"10px\">&nbsp;</td></tr>";
            dem++;
        }
    }
    public static string Get_ID(string str)
    {
        return Get_value(str, str.Split('_').Length);
    }
    public static string Get_value(string str, int possition)
    {
        return str.Split('_')[possition - 1];
    }
    protected void btnKiemTra_Click(object sender, EventArgs e)
    {
        foreach (string key in Request.Form.AllKeys)
        {
            if (key.Contains("check") == true)
            {
                tnmb = KetNoiCSDL.session.GetObjectByKey<TracNghiem_Members>(ConvertType.ToInt(Get_value(key,3)));
                tnmb.answer = Get_value(key,2).ToCharArray()[0];
                KetNoiCSDL.session.Save(tnmb);
            }
        }
        this.btnlamtiep.Enabled = true;
    }
    protected void btnlamtiep_Click(object sender, EventArgs e)
    {

    }
}
